package com.leoman.dao;

import com.leoman.entity.ThirdUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * ThirdUserDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:45.
 */
public interface ThirdUserDao extends JpaRepository<ThirdUser, Integer>, JpaSpecificationExecutor<ThirdUser> {

    @Query("select a from ThirdUser a where a.openId = ?1 and a.type = ?2")
    ThirdUser findOneByOpenIdAndType(String openId, Integer type);

    @Query("select a from ThirdUser a where a.user.id = ?1 and a.type = ?2")
    ThirdUser findOneByUserIdAndType(Integer userId, Integer type);
}